// 单例
let CreateSingleton = (function() {
    let a = null;
    return function(name) { //constructor

        if (a) {
            return a;
        }
        this.name = name;
        return a = this;
    }
})()
CreateSingleton.prototype.getname = function() {
    console.log(this.name);
}
let singleton = new CreateSingleton('yang');
let dalao = new CreateSingleton('xiang');
console.log(singleton == dalao);
singleton.getname();
dalao.getname();